#!/usr/bin/env/ python
# -*- coding: utf-8

"""
@project: python-file
@author: admin
@time: 2022/1/31
"""

import unittest
from BeautifulReport import BeautifulReport
import os

curpath = os.path.dirname(os.path.realpath(__file__))
casepath = os.path.join(curpath, "tests")
if not os.path.exists(casepath):
	print("测试用例需要放到'tests'文件目录下")
	os.mkdir(casepath)
reportpath = os.path.join(curpath, "report")
if not os.path.exists(reportpath) : os.mkdir(reportpath)

def add_case(case_path = casepath, rule = "test*.py"):
	'''加载所有的测试用例'''
	discover = unittest.defaultTestLoader.discover(case_path)
	return discover

def run(test_suit):
	result = BeautifulReport(test_suit)
	result.report(filename= "report.html",
	              description="测试deafult报告",
	              log_path="report")

if __name__ == '__main__':
    run(add_case())